<%@ page import="util.Validate" %> 
<%@ page import="prac.dao.SeongSuCondoDAO" %>
<%@ page import="java.util.HashMap, java.util.Enumeration" %>

<%
//===================== set response contentType ======================
	response.setContentType("text/html; charset=UTF-8");
%>

<%
// ============== define used variable on this command. ===============
	
	String action = "";
	String result = "";
	HashMap hm = new HashMap();

	Validate v = new Validate();
	SeongSuCondoDAO cDao = new SeongSuCondoDAO();

%>

<%
// ========== get the all of parameters from request object. ==========

	Enumeration em = request.getParameterNames();

	while(em.hasMoreElements()){
		String param_name = (String)em.nextElement();
		String [] param_value = request.getParameterValues(param_name);
		if(param_value != null && param_value.length > 0){
			if(param_value.length == 1){
				hm.put(param_name, param_value[0]);
			}else{
				hm.put(param_name, param_value);
			}
		}	// if
		
	}	// while
			
%>

<%
//=========== get the all of parameters from request object. ==========
	
 	if(hm.containsKey("action")){
		action = v.nullchk((String)hm.get("action"));
				
		try{
							
			if("create".equals(action)){
				
			/*
			* @author YeonJong Jeong.
			* @description create new condo item.
			* @params HashMap 
			*	@return String
			*/
				result = (String)cDao.add_condo_item(hm); 
					
			}else if("select".equals(action)){
				
			/*
			*	@author YeonJong Jeong.
			* @description fetch all of condo lists.
			* @return String
			*/
				
				result = (String)cDao.fetch_condo_list(hm); 
			
			}else if("delete".equals(action)){
				
			/*
			*	@author YeonJong Jeong.
			* @description delete selected condo items.
			* @params HashMap
			* @return String
			*/
			
				result = (String)cDao.delete_condo_item(hm);	 
				
			}else if("apply".equals(action)){
				
			/*
			*	@author YeonJong Jeong.
			* @description apply for selected condo item.
			* @params HashMap
			* @return String
			*/	
				
				result = (String)cDao.apply_condo_item(hm); 
														
			}else if("apply-select".equals(action)){
				
			/*
			*	@author YeonJong Jeong.
			* @description fetch applied condo item by individual.
			* @params HashMap
			* @return String
			*/
				
				result = (String)cDao.fetch_apply_condo_list(hm);
				
			}else if("apply-delete".equals(action)){
				
			/*
			*	@author YeonJong Jeong.
			* @description delete the applied condo item.
			* @params HashMap
			* @return String
			*/	
				
				result = (String)cDao.delete_apply_condo_item(hm); 
			
			}else if("apply-list-select".equals(action)){
				
			/*
			*
			*	fetch apply condo list.
			*
			* @param year
			* @param season
			*
			*/
			
				result = (String)cDao.fetch_excel_condo_list(hm.get("year").toString(), hm.get("season").toString());			
		
			}else if("test-select".equals(action)){
				
			/*
			*	@author YeonJong Jeong.
			* @description fetch applied condo item by individual.
			* @params HashMap
			* @return String
			*/
				
				result = (String)cDao.test_list();
				
			}else if("test-insert".equals(action)){
				
			/*
			*	@author YeonJong Jeong.
			* @description fetch applied condo item by individual.
			* @params HashMap
			* @return String
			*/
				
				result = (String)cDao.test_Insert(hm);
				
			}
		
		}catch(Exception e){
			e.printStackTrace();
		}
				
	}

%>

<%
	out.println(result);
%>
